package com.bawei.hgshop.common;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.kafka.listener.MessageListener;

import com.bawei.hgshop.entity.Category;

public class KfkMessageConsumer implements  MessageListener<String, String> {
	
	{
		System.out.println("消费者已经启动了。。。。。。。。。。。");   
	}

	// 注入redis
		@Autowired
		RedisTemplate<String, Category> catRedisTmp;
	
	@Override
	public void onMessage(ConsumerRecord<String, String> data) {
		// TODO Auto-generated method stub
		System.out.println("data is + " + data.key() + "  --- "+ data.value() );
		
		switch (data.key()) {
		case "cat":
			// 清理redis的缓存
			catRedisTmp.delete("cattree");
			break;
		default:
			break;
		}
		
	}

}
